<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //无条件成功 返回一个成功的promise
        Promise.resolve('我成功了').then(res => console.log(res))

        //无条件失败 返回一个失败的promise
        Promise.reject('失败').catch(err => console.log(err))

        let successFn = (data) => Promise.resolve(data)
        let arr = [];
        for (let i = 0; i <= 3; i++) {
            arr.push(successFn('成功' + i)) //劫持与监听
        }

        Promise.all(arr).then(arrData => console.log(arrData))


        let successFn1 = data => Promise.resolve(data)
        let arr1 = [];
        for (let i = 0; i < 3; i++) {
            arr1.push(successFn1('success' + 1))
        }
        Promise.all(arr1).then(arrData => console.log(arrData))
    </script>
</body>

</html>